﻿#ifndef PROTOHASH_H
#define PROTOHASH_H
#include <QVariant>
#include <QVector>

class ProtoHash
{
    friend class ProtoArray;
    friend QDebug operator<<(QDebug debug, const ProtoHash &hash);
public:
    ProtoHash();
    ProtoHash(const QVariantHash& variantHash);
    static QVariantHash decodeHash(const QByteArray& buf);
    int decode(const QByteArray& buf);
    QByteArray encode() const;
    void setParam(int key, const QVariant &variant);
    void clear();
private:
    QVariantHash hash;
};

QDebug operator<<(QDebug debug, const ProtoHash &hash);

class ProtoArray
{
    friend QDebug operator<<(QDebug debug, const ProtoArray &hash);
public:
    static QList<QVariantHash> decodeArray(const QByteArray& buf);
    int decode(const QByteArray& buf);
    QByteArray encode() const;
    QVariantList toVariantList() const;
    void clear();
private:
    QList<QVariantHash> list;
};

QDebug operator<<(QDebug debug, const ProtoArray &array);

#endif // PROTOHASH_H
